Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sync with Fabric Loader 0.16.2 #448

Merged
merged 9 commits into from
Aug 23, 2024
Merged

Sync with Fabric Loader 0.16.2 #448

merged 9 commits into from
Aug 23, 2024

Conversation

EnnuiL
Copy link
Contributor

@EnnuiL EnnuiL commented Aug 17, 2024

please?
(This update uses cherry picks (and a big revert of a revert) to sync with FLoader 0.16.2 (a merge was going to ruin everything), also it implements the FLoader entrypoint change to QLoader in order to avoid some torture)

EnnuiL and others added 7 commits August 17, 2024 00:07
* Added support for 1.21.2 in McVersionLookup

* Update minecraft/src/main/java/net/fabricmc/loader/impl/game/minecraft/McVersionLookup.java

Co-authored-by: modmuss <modmuss50@gmail.com>

---------

Co-authored-by: modmuss <modmuss50@gmail.com>
(cherry picked from commit 991d38d8a62e89f00aa3038b52f428f95b7d44bc)
@AlexIIL
Copy link
Contributor

AlexIIL commented Aug 17, 2024

Unfortunately the reason why we haven't updated to FLoader 0.16.x is we're encountering new issues with mixin - for example the first mixin in my tests fails with this error:

Caused by: java.lang.ClassFormatError: Duplicate method name "callIsNamespaceValid" with signature "(Ljava.lang.String;)Z" in class file org/quiltmc/qsl/resource/loader/mixin/IdentifierAccessor
	at java.base/java.lang.ClassLoader.defineClass1(Native Method)
	at java.base/java.lang.ClassLoader.defineClass(ClassLoader.java:1017)
	at java.base/java.security.SecureClassLoader.defineClass(SecureClassLoader.java:150)
	at org.quiltmc.loader.impl.launch.knot.KnotClassLoader.defineClassFwd(KnotClassLoader.java:3

crash-2024-08-17_05.05.06.8224-quilt_loader.txt

Inspecting the exported mixin file shows that the methods and annotation is duplicated:

$ javap -p -s -v IdentifierAccessor.class 

Classfile /<omitted>/QuiltLoaderTests/runs/20240817_050427/1.18.2-client/.mixin.out/class/org/quiltmc/qsl/resource/loader/mixin/IdentifierAccessor.class
  Last modified 17 Aug 2024; size 862 bytes
  SHA-256 checksum 6c78310c1ed3621d8e5a26a779837e6db37f6b525a48d5ffddca9a44e864799a
  Compiled from "IdentifierAccessor.java"
public interface org.quiltmc.qsl.resource.loader.mixin.IdentifierAccessor
  minor version: 0
  major version: 61
  flags: (0x0601) ACC_PUBLIC, ACC_INTERFACE, ACC_ABSTRACT
  this_class: #2                          // org/quiltmc/qsl/resource/loader/mixin/IdentifierAccessor
  super_class: #4                         // java/lang/Object
  interfaces: 0, fields: 0, methods: 2, attributes: 2
Constant pool:
   #1 = Utf8               org/quiltmc/qsl/resource/loader/mixin/IdentifierAccessor
   <snip>
  #27 = Utf8               RuntimeInvisibleAnnotations
{
  public static boolean callIsNamespaceValid(java.lang.String);
    descriptor: (Ljava/lang/String;)Z
    flags: (0x1009) ACC_PUBLIC, ACC_STATIC, ACC_SYNTHETIC
    Code:
      stack=1, locals=1, args_size=1
         0: aload_0
         1: invokestatic  #20                 // Method net/minecraft/class_2960.callIsNamespaceValid$quilt_resource_loader_$md$b666f8$0:(Ljava/lang/String;)Z
         4: ireturn
      LocalVariableTable:
        Start  Length  Slot  Name   Signature
            0       0     0 namespace   Ljava/lang/String;
    RuntimeVisibleAnnotations:
      0: #12()
        org.spongepowered.asm.mixin.gen.Invoker
      1: #13(#14=s#15)
        org.spongepowered.asm.mixin.transformer.meta.MixinProxy(
          sessionId="bffba2d2-646f-4ad9-9cca-c3cce8b666f8"
        )
    MethodParameters:
      Name                           Flags
      namespace

  public static boolean callIsNamespaceValid(java.lang.String);
    descriptor: (Ljava/lang/String;)Z
    flags: (0x1009) ACC_PUBLIC, ACC_STATIC, ACC_SYNTHETIC
    Code:
      stack=1, locals=1, args_size=1
         0: aload_0
         1: invokestatic  #20                 // Method net/minecraft/class_2960.callIsNamespaceValid$quilt_resource_loader_$md$b666f8$0:(Ljava/lang/String;)Z
         4: ireturn
      LocalVariableTable:
        Start  Length  Slot  Name   Signature
            0       0     0 namespace   Ljava/lang/String;
    RuntimeVisibleAnnotations:
      0: #12()
        org.spongepowered.asm.mixin.gen.Invoker
      1: #13(#14=s#15)
        org.spongepowered.asm.mixin.transformer.meta.MixinProxy(
          sessionId="bffba2d2-646f-4ad9-9cca-c3cce8b666f8"
        )
    MethodParameters:
      Name                           Flags
      namespace
}
SourceFile: "IdentifierAccessor.java"
RuntimeInvisibleAnnotations:
  0: #6(#7=[c#8])
    org.spongepowered.asm.mixin.Mixin(
      value=[class Lnet/minecraft/class_2960;]
    )
  1: #6(#7=[c#8])
    org.spongepowered.asm.mixin.Mixin(
      value=[class Lnet/minecraft/class_2960;]
    )

@EnnuiL
Copy link
Contributor Author

EnnuiL commented Aug 17, 2024

Unfortunately the reason why we haven't updated to FLoader 0.16.x is we're encountering new issues with mixin - for example the first mixin in my tests fails with this error:

Caused by: java.lang.ClassFormatError: Duplicate method name "callIsNamespaceValid" with signature "(Ljava.lang.String;)Z" in class file org/quiltmc/qsl/resource/loader/mixin/IdentifierAccessor
	at java.base/java.lang.ClassLoader.defineClass1(Native Method)
	at java.base/java.lang.ClassLoader.defineClass(ClassLoader.java:1017)
	at java.base/java.security.SecureClassLoader.defineClass(SecureClassLoader.java:150)
	at org.quiltmc.loader.impl.launch.knot.KnotClassLoader.defineClassFwd(KnotClassLoader.java:3

crash-2024-08-17_05.05.06.8224-quilt_loader.txt

Inspecting the exported mixin file shows that the methods and annotation is duplicated:

$ javap -p -s -v IdentifierAccessor.class 

Classfile /<omitted>/QuiltLoaderTests/runs/20240817_050427/1.18.2-client/.mixin.out/class/org/quiltmc/qsl/resource/loader/mixin/IdentifierAccessor.class
  Last modified 17 Aug 2024; size 862 bytes
  SHA-256 checksum 6c78310c1ed3621d8e5a26a779837e6db37f6b525a48d5ffddca9a44e864799a
  Compiled from "IdentifierAccessor.java"
public interface org.quiltmc.qsl.resource.loader.mixin.IdentifierAccessor
  minor version: 0
  major version: 61
  flags: (0x0601) ACC_PUBLIC, ACC_INTERFACE, ACC_ABSTRACT
  this_class: #2                          // org/quiltmc/qsl/resource/loader/mixin/IdentifierAccessor
  super_class: #4                         // java/lang/Object
  interfaces: 0, fields: 0, methods: 2, attributes: 2
Constant pool:
   #1 = Utf8               org/quiltmc/qsl/resource/loader/mixin/IdentifierAccessor
   <snip>
  #27 = Utf8               RuntimeInvisibleAnnotations
{
  public static boolean callIsNamespaceValid(java.lang.String);
    descriptor: (Ljava/lang/String;)Z
    flags: (0x1009) ACC_PUBLIC, ACC_STATIC, ACC_SYNTHETIC
    Code:
      stack=1, locals=1, args_size=1
         0: aload_0
         1: invokestatic  #20                 // Method net/minecraft/class_2960.callIsNamespaceValid$quilt_resource_loader_$md$b666f8$0:(Ljava/lang/String;)Z
         4: ireturn
      LocalVariableTable:
        Start  Length  Slot  Name   Signature
            0       0     0 namespace   Ljava/lang/String;
    RuntimeVisibleAnnotations:
      0: #12()
        org.spongepowered.asm.mixin.gen.Invoker
      1: #13(#14=s#15)
        org.spongepowered.asm.mixin.transformer.meta.MixinProxy(
          sessionId="bffba2d2-646f-4ad9-9cca-c3cce8b666f8"
        )
    MethodParameters:
      Name                           Flags
      namespace

  public static boolean callIsNamespaceValid(java.lang.String);
    descriptor: (Ljava/lang/String;)Z
    flags: (0x1009) ACC_PUBLIC, ACC_STATIC, ACC_SYNTHETIC
    Code:
      stack=1, locals=1, args_size=1
         0: aload_0
         1: invokestatic  #20                 // Method net/minecraft/class_2960.callIsNamespaceValid$quilt_resource_loader_$md$b666f8$0:(Ljava/lang/String;)Z
         4: ireturn
      LocalVariableTable:
        Start  Length  Slot  Name   Signature
            0       0     0 namespace   Ljava/lang/String;
    RuntimeVisibleAnnotations:
      0: #12()
        org.spongepowered.asm.mixin.gen.Invoker
      1: #13(#14=s#15)
        org.spongepowered.asm.mixin.transformer.meta.MixinProxy(
          sessionId="bffba2d2-646f-4ad9-9cca-c3cce8b666f8"
        )
    MethodParameters:
      Name                           Flags
      namespace
}
SourceFile: "IdentifierAccessor.java"
RuntimeInvisibleAnnotations:
  0: #6(#7=[c#8])
    org.spongepowered.asm.mixin.Mixin(
      value=[class Lnet/minecraft/class_2960;]
    )
  1: #6(#7=[c#8])
    org.spongepowered.asm.mixin.Mixin(
      value=[class Lnet/minecraft/class_2960;]
    )

FLoader 0.16.2 is still a mess? damn, and i thought y'all were allergic to updates;
i guess i should close this PR then? it's not useful 'til they sort out this problem

@EnnuiL EnnuiL closed this Aug 17, 2024
@AlexIIL
Copy link
Contributor

AlexIIL commented Aug 17, 2024

reader.accept(node, 0);
reader.accept(node, readerFlags);

erm, I think that might be it lol. I haven't finished testing it yet though :p

@AlexIIL AlexIIL reopened this Aug 17, 2024
@AlexIIL
Copy link
Contributor

AlexIIL commented Aug 17, 2024

It turns out it's our fault. Or at least it's our fault until someone else who encountered mixin problems initially can reproduce them.

Thanks for opening this PR! I wouldn't have taken a proper look into this if you didn't open this :D

@AlexIIL
Copy link
Contributor

AlexIIL commented Aug 17, 2024

...and I spoke too soon. Sorry :(

Caused by: org.spongepowered.asm.mixin.injection.throwables.InjectionError: LVT in net/minecraft/class_3218::method_8413(Lnet/minecraft/class_2338;Lnet/minecraft/class_2680;Lnet/minecraft/class_2680;I)V has incompatible changes at opcode 59 in callback #lithium:lithium.mixins.json:entity.inactive_navigations.ServerWorldMixin from mod lithium->@Inject::updateActiveListeners(Lnet/minecraft/class_2338;Lnet/minecraft/class_2680;Lnet/minecraft/class_2680;ILorg/spongepowered/asm/mixin/injection/callback/CallbackInfo;Lnet/minecraft/class_265;Lnet/minecraft/class_265;Ljava/util/List;)V.
Expected: [Lnet/minecraft/class_265;, Lnet/minecraft/class_265;, Ljava/util/List;]
Found: [Ljava/util/List;]

crash-2024-08-17_05.48.32.2111-quilt_loader.txt

@EnnuiL
Copy link
Contributor Author

EnnuiL commented Aug 17, 2024

...and I spoke too soon. Sorry :(

Caused by: org.spongepowered.asm.mixin.injection.throwables.InjectionError: LVT in net/minecraft/class_3218::method_8413(Lnet/minecraft/class_2338;Lnet/minecraft/class_2680;Lnet/minecraft/class_2680;I)V has incompatible changes at opcode 59 in callback #lithium:lithium.mixins.json:entity.inactive_navigations.ServerWorldMixin from mod lithium->@Inject::updateActiveListeners(Lnet/minecraft/class_2338;Lnet/minecraft/class_2680;Lnet/minecraft/class_2680;ILorg/spongepowered/asm/mixin/injection/callback/CallbackInfo;Lnet/minecraft/class_265;Lnet/minecraft/class_265;Ljava/util/List;)V. Expected: [Lnet/minecraft/class_265;, Lnet/minecraft/class_265;, Ljava/util/List;] Found: [Ljava/util/List;]

crash-2024-08-17_05.48.32.2111-quilt_loader.txt

hm, are you sure this doesn't have anything to do with mixin compatibility shenanigans? (also, something tells me that quilt should perhaps adopt a "0.27.0+ shall be mixin 0.14.0" thingy instead of being always latest)

@AlexIIL
Copy link
Contributor

AlexIIL commented Aug 17, 2024

Possibly, in this case lithium requires fabric-loader 0.12.11, so uses 0.9.2 mixin compatibility.
([main/DEBUG]: Mod lithium requires loader version 0.12.11, using 0.9.2 mixin compatability)
An older version of loader had a different log line:
[main/DEBUG]: Mod lithium requires loader version 0.12.11, using mixin compatibility 10000

@EnnuiL
Copy link
Contributor Author

EnnuiL commented Aug 17, 2024

Possibly, in this case lithium requires fabric-loader 0.12.11, so uses 0.9.2 mixin compatibility. ([main/DEBUG]: Mod lithium requires loader version 0.12.11, using 0.9.2 mixin compatability) An older version of loader had a different log line: [main/DEBUG]: Mod lithium requires loader version 0.12.11, using mixin compatibility 10000

ok yeah, this is wrong; if you have an explicit dep on floader 0.12.0-, you have 0.10.0 mixin compat mode; this explains why the errors are all reminiscent of mixin 0.9.2 shenanigans

this will need a massive refactoring though, so that quilt mods are also accounted into this system (they do still exist! kinda!), so yeah, maybe this is no longer my job and now it's yours? :p

@AlexIIL
Copy link
Contributor

AlexIIL commented Aug 17, 2024

So loader's mixin compatibility test code looks like this:

for (LoaderMixinVersionEntry version : versions) {
	if (minLoaderVersion.compareTo(version.loaderVersion) >= 0) { // lower bound is >= current version
		Log.debug(LogCategory.MIXIN, "Mod %s requires loader version %s, using mixin compatibility %s", metadata.id(), minLoaderVersion, version.mixinVersion);
		return version.mixinVersion;
	} else {
		Log.debug(LogCategory.MIXIN, "Mod %s requires loader version %s, using 0.9.2 mixin compatability", metadata.id(), minLoaderVersion);
		return FabricUtil.COMPATIBILITY_0_9_2;
	}
}

facepalm.

Well, that was an easy fix...
(This happened because we've never had multiple mixin compatibility versions before, so this was untested).

so that quilt mods are also accounted into this system (they do still exist! kinda!)

Yeah, that's a good point! All quilt mods currently get the latest mixin version, no compat code applied :/

@ix0rai ix0rai linked an issue Aug 19, 2024 that may be closed by this pull request
Copy link
Member

@TheGlitch76 TheGlitch76 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Having to do the same hack that Fabric does in our loader makes me sad, because Mixin behavior changing based on the dependency in your QMJ is the worst possible UX. However, pinning everything to 0.10.0 for now seems like a good stopgap.

@LlamaLad7
Copy link

Mixin behavior changing based on the dependency in your QMJ is the worst possible UX

How so?

@TheGlitch76
Copy link
Member

Mixin behavior changing based on the dependency in your QMJ is the worst possible UX

How so?

I'm being a little dramatic (after all, I can't think of a better option), but I think it's very surprising behavior that the minimum version set in the mod metadata influences mixin. Nobody would reasonably expect local capture (iirc, i'm a little rusty) to change behavior based on if they had put a * or >=0.12.0 as their dependency for fabricloader.

@LlamaLad7
Copy link

Seems fairly reasonable to me that changing your min version would opt you into new behaviours.

@AlexIIL
Copy link
Contributor

AlexIIL commented Aug 22, 2024

I'd definitely prefer it if you could change the mixin compatibility level separately to the loader version - since they are two separate libraries. But not in this pull request, since it feels somewhat separate from updating to floader 1.16.2

@LlamaLad7
Copy link

a. changing the dep doesn't opt you into any other behaviours, it's just for mixin (afaik)
b. to get the new mixin behaviours you inherently need to require that loader version or the behaviours won't be present

@EnnuiL
Copy link
Contributor Author

EnnuiL commented Aug 22, 2024

Yeah, I feel like a pin to 0.10.0 will be good enough to let us think about another solution for now; but maybe we could have the QLoader min version be a fallback of some sorts (but also have it be explicitly printed on the logs) in favor of explicit mixin compat on maybe the QMJ? The template mod is always here to help with good practices

@kb-1000
Copy link
Contributor

kb-1000 commented Aug 22, 2024

Mixin behavior changing based on the dependency in your QMJ is the worst possible UX

How so?

How is it not? For fabric, is this even documented anywhere outside the code or logging? When I saw this in floader's code I was quite surprised.
As a mod dev (and linux packager), I would not expect a dependency to affect anything after dependency resolving. This is not the documented or intended purpose of dependencies. If you ask me, this is bad practice and a pretty bad idea. I suppose it'd be too late to change this retroactively but it doesn't have to (or should) continue this way.

@LostLuma
Copy link
Contributor

I'd definitely prefer it if you could change the mixin compatibility level separately to the loader version

Isn't that what the minVersion property in the mixins json file is for (or at least I'd expect that as an unsuspecting user)?

@EnnuiL
Copy link
Contributor Author

EnnuiL commented Aug 22, 2024

Folks, can we have a separate issue created please? I'd rather have the FLoader 0.16.2 compatibility merged asap than having to worry about Quilt mods' mixin compat shenanigans and stall the compat even further; we can have the compat as a 0.27.0-beta.1, then we can figure out a good solution for Quilt later; the thing is: we took way too long to be compatible with that update in the name of "yes Fabric will fix their stuff" when we were actually broken all along, so can we please not bikeshed this PR? thank you

AlexIIL added a commit that referenced this pull request Aug 23, 2024
Manually merged to not loose history.

Also includes a changelog, and new loader beta version
@AlexIIL AlexIIL merged commit bcd60aa into QuiltMC:develop Aug 23, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Fabric loader 0.16.0
9 participants